<?php

function UnzipProject($loadpath, $project)
{
    global $staging_path;
// We will unpack it to a sibling directory.
    $targetpath = build_path($staging_path, $project->ProjectId());

    if (! file_exists($targetpath) )
    {
        mkdir($targetpath, 0777);
    }
    else
    {
        chmod($targetpath, 0777);
    }

    $zip = new ZipArchive();
    $zip.open($loadpath);
    $zip.extractTo($targetpath)
    $zip.close();
    unlink($loadpath);


do_redirect("{$code_url}/filemaster.php?projectid={$projectid}"
                ."&amp;loadpath={$loadpath}");


// vim: sw=4 ts=4 expandtab
?>
